<?php

namespace App\Console\Commands\Chanjet;

use App\Http\Controllers\Chanjet\TplusCommonController;
use App\Models\Chanjet\TplusToken;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class PaymentLedger extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:PaymentLedger';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '应付总账';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $TplusToken = TplusToken::where('is_valid',0)->select(['org_id','access_token'])->get();
        $common = new TplusCommonController();
        foreach ($TplusToken as $item) {
            $res = $common->getExternalData('TplusPaymentLedger',$item['org_id'],[],$item['access_token']);
            //Log::info($this->description.",org_id:".$item['org_id'].",".$res['data']);
        }
        return 0;
    }
}
